#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#include <immintrin.h>
//#include <emmintrin.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define pii pair<int,int>
#define fi first
#define se second
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
mt19937_64 rnd(time(0));
#define rand() abs((int)rnd())
const int N=1e6+5,base=999983,Mod=998244353;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
//int _base=1;
//inline int mol(const int x){return x-Mod*((__int128)_base*x>>64);}
//inline void Add(int &x,const int y){x=mol(x+y);}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,m;
int a[N],b[N];
inline int ksm(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}return res;
}int dp[20][N];
signed main(){
//	_base=((__int128)_base<<64)/Mod;
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read(),m=read();int mx=0,sum=0;
	For(i,1,n) a[i]=read(),b[i]=read(),mx=max(mx,b[i]),sum+=b[i];
	if(n==1){
		printf("%lld\n",ksm(a[1],m));
		return 0;
	}
	if(mx<=300){
		dp[0][0]=1;
		For(i,1,n){
			For(t,0,min(sum,m))if(dp[i-1][t])
			For(j,0,min(b[i],m-t)){
				dp[i][t+j]+=dp[i-1][t]*ksm(a[i],j);
				dp[i][t+j]%=Mod;
			}
		}printf("%lld\n",dp[n][m]);
		return 0;
	}if(n==2){
		int A=a[1],B=a[2];
		if(A<B) swap(A,B),swap(b[1],b[2]);
		int ans=(ksm(A,m+1)-ksm(B,m+1)+Mod)*ksm(A-B,Mod-2)%Mod;
		if(b[1]<m){
			ans-=ksm(A,b[1]+1)*((ksm(A,m-b[1])-ksm(B,m-b[1])+Mod)*ksm(A-B,Mod-2)%Mod)%Mod;
			ans+=Mod;ans%=Mod;
		}if(b[2]<m){
			ans-=ksm(B,b[2]+1)*((ksm(A,m-b[2])-ksm(B,m-b[2])+Mod)*ksm(A-B,Mod-2)%Mod)%Mod;
			ans+=Mod;ans%=Mod;
		}printf("%lld\n",ans);
		return 0;
	}bool flag=0;
	For(i,1,n) if(b[i]<m) flag=1;
	if(!flag){
		sum=0;
		For(i,1,n) sum+=a[i];sum%=Mod;
		printf("%lld\n",ksm(sum,m));
		return 0;
	} 
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

